<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="/js/jquery.leanModal.min.js"></script>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<link rel="stylesheet" href="/js/chosen/chosen.css" />
<script>
$(function() {

	$( "#date_begin" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 ,beforeShowDay: function(date){ return [date.getDay() == 1,""]}});
	
});
</script>
<style>
.font{font-size:12px}
</style>

</head>

<body style="font-family:Arial, Helvetica, sans-serif">
<form method = "post" action = "">
<h1>Expense Summary</h1>
Select Week:<input type = "text" name = "date_begin" id = "date_begin"></input><input type = "submit" name = "submit" value = "Submit" ></input>
<?php if($this->dateBegin && $this->dateEnd){?>
<table  border="1" cellspacing="1" cellpadding="5" class="font">

<?php $dateArray = Model_DatetimeHelper::createDateArray($this->dateBegin, $this->dateEnd);
	  $allTotal = 0;?>
	<tr>
		<th>Shop</th>
		<?php foreach ($dateArray as $k => $v){?>
			<th width="200"><?php echo $v?></th>
		<?php }?>
		<th>Total</th>
	</tr>
	<?php foreach ($this->record as $k2 => $v2){
			$shopTotal = 0;?>
		<tr>
			<td><?php echo $k2?></td>
			<?php foreach ($v2 as $k3 => $v3){?>
				<td width="200"><?php if($v3['sub_expense_total'] == 0){echo "";}else{ 
						if($v3['sub_expense_1']!= 0){
							?>	
							<table>
								<tr>
									<td><?php echo "$".$v3['sub_expense_1']?></td>
									<td><?php echo $v3['product_expense_1']?></td>
									<td><?php echo "STF:".$v3['staff_name_expense_1']?></td>
								</tr>
							</table><br/>
							<?php $shopTotal+= $v3['sub_expense_1'];
								 
						}
						if($v3['sub_expense_2']!= 0){?>
							<table>
								<tr>
									<td><?php echo "Cost:$".$v3['sub_expense_2']?></td>
									<td><?php echo $v3['product_expense_2']?></td>
									<td><?php echo "STF:".$v3['staff_name_expense_2']?></td>

								</tr>
							</table><br/>
							<?php $shopTotal+= $v3['sub_expense_2'];
								  
						}
						if($v3['sub_expense_3']!= 0){?>
							<table>
								<tr>
									<td><?php echo "Cost:$".$v3['sub_expense_3']?></td>
									<td><?php echo $v3['product_expense_3']?></td>
									<td><?php echo "STF:".$v3['staff_name_expense_3']?></td>
								</tr>
							</table><br/>
							<?php $shopTotal+= $v3['sub_expense_3'];
						}
						if($v3['sub_expense_4']!= 0){?>
							<table>
								<tr>
									<td><?php echo "Cost:$".$v3['sub_expense_4']?></td>
									<td><?php echo $v3['product_expense_4']?></td>
									<td><?php echo "STF:".$v3['staff_name_expense_4']?></td>
								</tr>
							</table><br/>
							<?php $shopTotal+= $v3['sub_expense_4'];
								
						}
						if($v3['sub_expense_5']!= 0){?>
							<table>
								<tr>
									<td><?php echo "Cost:$".$v3['sub_expense_5']?></td>
									<td><?php echo $v3['product_expense_5']?></td>
									<td><?php echo "STF:".$v3['staff_name_expense_5']?></td>
								</tr>
							</table><br/>
							<?php $shopTotal+= $v3['sub_expense_5'];
								  
						}
						if($v3['sub_expense_6']!= 0){?>
							<table>
								<tr>
									<td><?php echo "Cost:$".$v3['sub_expense_6']?></td>
									<td><?php echo $v3['product_expense_6']?></td>
									<td><?php echo "STF:".$v3['staff_name_expense_6']?></td>
								</tr>
							</table><br/>
							<?php $shopTotal+= $v3['sub_expense_6'];
								  $allTotal += $shopTotal;
						}?>
						<?php echo "MGR:".$v3['expense_approved_manager']?>
					<?php }?>
				</td>
			
			<?php }?>
			<td><?php echo $shopTotal;?></td>
		</tr>
	<?php $allTotal += $shopTotal;}?>
	<tr>
		<td colspan = "<?php echo (count($dateArray)+2)?>" align = "right">Total:<?php echo $allTotal;?></td>
	</tr>
</table>
<?php }?>
<br/><br/>			

</form>
</body>
</html>
